<template>
  <g-details :detailData="inputData" :inputConfig="inputConfig" :rules="rules" @pop="setdata" ref="detail"> </g-details>
</template>

<script>
import baseMixin from '@/mixins/BaseMixin'
export default {
  name: 'dispatchDetails',
  mixins: [baseMixin],
  props: {
    inputData: {
      type: Object
    }
  },
  data() {
    return {
      rules: {
        deliveryDeptName: [
          {
            required: true,
            message: this.$selectPlease('model.deliveryDept'),
            trigger: 'blur'
          }
        ],
        materialType: [
          {
            required: true,
            message: this.$selectPlease('model.materialType'),
            trigger: 'blur'
          }
        ],
        deliveryType: [
          {
            required: true,
            message: this.$selectPlease('model.deliveryType'),
            trigger: 'blur'
          }
        ]
      }
    }
  },
  computed: {
    inputConfig() {
      return [
        {
          type: 'input',
          label: '工位耗用/H',
          props: 'code111'
        },
        {
          type: 'input',
          label: '线边仓存储位置',
          props: 'materialType',
        },
        {
          type: 'input',
          label: '工装器具',
          props: 'deliveryStatus',
          break: true
        },
        {
          type: 'input',
          label: '工位名称',
          props: 'deliveryType',
        },
        {
          type: 'input',
          label: '工位最大存量',
          props: 'materialType'
        },
        {
          type: 'input',
          label: '接收区域',
          props: 'totalRows',
          break: true
        },
        {
          type: 'input',
          label: 'BOM用量',
          props: 'totalRows',
        },
        {
          type: 'input',
          label: '工位最小存量',
          props: 'totalRows',
        },
        {
          type: 'input',
          label: '供应类型',
          props: 'totalRows',
          break: true
        },
        {
          type: 'input',
          label: 'BOM上级',
          props: 'totalRows',
        },
        {
          type: 'input',
          label: '运输工具(到工位)',
          props: 'totalRows',
        },
        {
          type: 'input',
          label: '换包装地址',
          props: 'totalRows',
          break: true
        },
        {
          type: 'input',
          label: '成品型号',
          props: 'totalRows',
        },
        {
          type: 'input',
          label: '运输工具(到线边仓)',
          props: 'totalRows',
        },
        {
          type: 'input',
          label: '配送距离',
          props: 'totalRows',
          break: true
        },
        {
          type: 'input',
          label: '线边仓库存',
          props: 'totalRows',
        },
        {
          type: 'input',
          label: '运输工具(到备料区)',
          props: 'totalRows',
        },
        {
          type: 'datetime',
          label: '配送时间',
          props: 'totalRows',
          break: true
        },
        {
          type: 'input',
          label: '单位重量',
          props: 'totalRows',
        },
        {
          type: 'input',
          label: '配送路线(经过站点)',
          props: 'totalRows',
        },
      ]
    }
  },
  methods: {
    setdata(data, close, prop) {
      if (prop == 'deliveryDeptName') {
        this.inputData.deliveryDeptName = data.deptName
        this.inputData.deliveryDeptId = data.id
        const index = this.inputConfig.findIndex(
          item => item.props == 'deliveryMklineNo'
        )
        this.inputConfig[
          index
        ].url = `/baFactoryDeptLine/selectBaFactoryDeptLineList/${data.id}`
      } else if (prop == 'deliveryMklineNo') {
        this.inputData.deliveryDeptName = data.deptName
        this.inputData.deliveryDeptId = data.deptId
        this.inputData.deliveryMklineNo = data.deptLineNo
        this.inputData.deliveryMklineName = data.deptLineName
      }
      close(false)
    },
    validate() {
      return this.$refs.detail.$refs.from.validate()
    }
  },
  mounted() {}
}
</script>

<style scoped>
</style>
